/**
 * @author lk
 * @date 2022/6/1 15:42
 */
package com.mmall.spring5;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component(value = "myUser")
public class User {

    public User(String name) {
        this.name = name;
    }

//    @Override
//    public String toString() {
//        return "User{" +
//                "name='" + name + '\'' +
//                '}';
//    }

    public String getName() {
        return name;
    }

    @Value("Jackson")
    private String name ;

    public User() {
        System.out.println("1.User类的无参构造器执行完毕了...");
    }

    public void setName(String name) {
        this.name = name;
        System.out.println("2.User类的setName方法执行完了...");
    }

    //初始化执行方法，需要在xml中指定
    public void initMethod() {
        System.out.println("4.User类的initMethod方法执行了...");
    }

    //销毁方法，需要在xml中指定
    public void destroyMethod() {
        System.out.println("6.User类的destroy方法执行了...");
    }
}
